package com.koron.device.controller;

import com.koron.bean.base.Response;
import com.koron.device.bean.SKksCode;
import com.koron.device.service.SKksCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * kks分类编码字典(SKksCode)表控制层
 *
 * @author makejava
 * @since 2023-06-27 16:06:59
 */
@RestController
@Api(tags = "kks编码字典")
@RequestMapping("/sKksCode")
public class SKksCodeController {
    /**
     * 服务对象
     */
    @Resource
    private SKksCodeService sKksCodeService;

    /**
     * 分页查询
     *
     * @param sKksCode    筛选条件
     * @return 查询结果
     */
    @ApiOperation(value = "分页查询")
    @GetMapping("/queryByPage")
    public Response queryByPage(SKksCode sKksCode) {
        return Response.ok(sKksCodeService.getPage(sKksCode));
    }

    /**
     *
     * @return 单条数据
     */
    @ApiOperation(value = "按名称查询编码")
    @GetMapping("/queryByName")
    public Response<SKksCode> queryByName(String name) {
        return Response.ok(sKksCodeService.queryByName(name));
    }

    /**
     * 新增数据
     *
     * @param sKksCode 实体
     * @return 新增结果
     */
    @ApiOperation(value = "新增编码")
    @PostMapping("/add")
    public Response add(@RequestBody SKksCode sKksCode) {
        return Response.ok(sKksCodeService.insert(sKksCode));
    }

    /**
     * 编辑数据
     *
     * @param sKksCode 实体
     * @return 编辑结果
     */
    @ApiOperation(value = "编辑编码")
    @PutMapping("/edit")
    public Response edit(SKksCode sKksCode) {
        return Response.ok(sKksCodeService.update(sKksCode));
    }

    /**
     * 删除数据
     *
     * @return 删除是否成功
     */
    @ApiOperation(value = "删除编码")
    @DeleteMapping("/deleteById")
    public Response deleteById(String id) {

        return Response.ok(sKksCodeService.deleteById(id));
    }

}

